/*
 *  surface.h
 *  EPPI-0.0
 *
 *  Created by Juan Carlos García Orden on 06/04/11.
 *
 */

#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET

#ifndef _surface_h_
#define _surface_h_

#include <Eigen/Dense>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <math.h>
#include "commonutil.h"

#define pii 3.14159265358979

using namespace std;

class Surface
{
public:
	
	string name;
	
	vector<vector<double> > vLocalPoints;
	vector<vector<int> > vLocalElements;
	vector<vector<double> > vContactPoints;
	
	int nLocalPoints;
	int nLocalElements;
	
	string pointsOption;
	string contactFileName;
	
	bool contactAllOption;
	bool contactFileOption;	

	ifstream inContact;
	
	double S;
	Eigen::RowVector3d dS;
	Eigen::Matrix3d ddS;
	
public:
	
	Surface();
	
	virtual ~Surface();

	Surface(const string&);
	
	Surface(const string&, vector<vector<double> >&, vector<vector<int> >&);	
	
	//-- Local functions --//
	
	void createCuboid(void);
	
	void createContactPoints(void);
	
	void writeVTU(vector<double>&, vector<vector<double> >&, ofstream&);

	double sgn(double);
	
	//-- Virtual functions --//
	
	virtual double evalS(double&, double&, double&) = 0;
	
	virtual Eigen::RowVector3d evaldS(double&, double&, double&) = 0;
	
	virtual Eigen::Matrix3d evalddS(double&, double&, double&) = 0;
		
	
	//-- Friend functions --//
	
	friend void rigidTrans(vector<double>&, vector<double>&, vector<vector<double> >&, vector<double>&);
	
	friend string getStringExtension(const string& str);
	
	friend void printSTLMatrix(const vector< vector<double> >&);
	
	friend void printSTLVector(const vector<double>&);
	
	friend void printSTLMatrix(const vector< vector<int> >&);
};
#endif